<template>
  <div class="userspace-container">
    <div class="icon-container">
      <el-avatar
        style="border: 4px solid #eee"
        :size="150"
        :src="userAvatar"
      ></el-avatar>
      <p style="font-weight: bold; font-size: 1.714rem">{{ userInfo.name }}</p>
      <p style="color: #8c92a4; margin-bottom: 2px">{{ userInfo.email }}</p>
      <p style="color: #8c92a4; margin-bottom: 2px">{{ userInfo.describe }}</p>
      <div class="data-contex">
        <div class="item">
          <p class="item-num">{{ modelNume }}</p>
          <p class="item-nam">模型</p>
        </div>
        <div class="item">
          <p class="item-num">{{ dataNume }}</p>
          <p class="item-nam">数据</p>
        </div>
        <div class="item">
          <p class="item-num">{{ parameterNume }}</p>
          <p class="item-nam">参数</p>
        </div>
      </div>
    </div>
    <div class="data-container">
      <div class="data-head">
        <el-menu
          default-active="1"
          class="el-menu-userspace"
          mode="horizontal"
          active-text-color="#1479d7"
          @select="menuSelect"
        >
          <el-menu-item index="1">
            <i class="fa-solid fa-code"></i>
            <span>模型</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="fa-solid fa-database"></i>
            <span>数据</span>
          </el-menu-item>
          <el-menu-item index="3">
            <i class="fa-solid fa-file-contract"></i>
            <span>参数</span>
          </el-menu-item>
        </el-menu>
        <div
          class="line"
          style="
            border-style: solid;
            border-color: #eaeaea;
            border-width: 0.1px;
          "
        ></div>
      </div>
      <div class="data-content">
        <component :is="componentID"></component>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import "../../assets/css/userspacemain.css";
import { config } from "../../plugins/config.js";
import UserSpaceMain from "./UserSpaceModels.vue";
import UserSpaceData from "./UserSpaceData.vue";
import UserSpaceParam from "./UserSpaceParam.vue";
export default {
  data() {
    return {
      userInfo: JSON.parse(localStorage.getItem("user")),
      userAvatar: "userImg/admin.jpg",
      ip: config.ip,
      modelNume: 10,
      dataNume: 56,
      parameterNume: 1,
      componentID: "UserSpaceMain",
    };
  },
  methods: {
    menuSelect(key, keyPath) {
      switch (key) {
        case "1":
          this.componentID = "UserSpaceMain";
          break;
        case "2":
          this.componentID = "UserSpaceData";
          break;
        case "3":
          this.componentID = "UserSpaceParam";
          break;
        default:
          break;
      }
    },
  },
  mounted() {
    const _this = this;
    this.userAvatar = this.ip + this.userInfo.avatar;
  },
  components: {
    UserSpaceMain: UserSpaceMain,
    UserSpaceData: UserSpaceData,
    UserSpaceParam: UserSpaceParam,
  },
};
</script>